<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/home_sharing_system/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function chkinput(){
	var propertyId = document.form.propertyId.selectedIndex;
	var privacyId = document.form.privacyId.selectedIndex;
	var accommodates = document.form.accommodates.selectedIndex;
	var bedrooms = document.form.bedrooms.selectedIndex;
	var title = document.form.title;
	var description = document.form.description;
	var phone_1 = document.form.phone_1.selectedIndex;
	var phone_2 = document.form.phone_2;
	var phone_3 = document.form.phone_3;
	var nation = document.form.nation;
	var zipcode = document.form.zipcode;
	
 	if(propertyId=="0"){
		alert("객실종류를 선택해주세요.");
		return false;
	}
 	if(privacyId=="0"){
		alert("랜탈범위를 선택해주세요.");
		return false;
	} 
 	if(accommodates=="0"){
		alert("숙박가능인원을 선택해주세요.");
		return false;
	}
 	if(bedrooms=="0"){
		alert("침실수를 선택해주세요.");
		return false;
	}
	if(title.value==""){
		alert("제목을 입력해주세요.");
		title.focus();
		return false;
	}
	if(description.value==""){
		alert("설명을 입력해주세요.");
		description.focus();
		return false;
	}
  	if(phone_1=="0"){
		alert("휴대폰번호를 선택해주세요.");
		return false;
	} 
	if(phone_2.value==""){
		alert("전화번호를 입력해주세요.");
		phone_2.focus();
		return false;
	}
	if(phone_3.value==""){
		alert("전화번호를 입력해주세요.");
		phone_3.focus();
		return false;
	}
	if(nation.value==""){
		alert("국가를 입력해주세요.");
		nation.focus();
		return false;
	}
	if(zipcode.value==""){
		alert("우편번호를 입력해주세요.");
		return false;
	}
}
function searchAddress(){
	window.open("address_popup.jsp","주소검색","scrollbars=yes,width=300,height=300 ,top=100,left=900");
	var e2 = document.getElementById("e2");
	e2.disabled=true;
	var e3 = document.getElementById("e3");
	e3.disabled=true;
	var e4 = document.getElementById("e4");
	e4.disabled=true;
	var e5 = document.getElementById("e5");
	e5.disabled=true;
}

$(document).ready(function(){
	var property = '${requestScope.rdto.propertyId }';
	$("#propertyId").val(property);
	var privacy = '${requestScope.rdto.privacyId }';
	$("#privacyId").val(privacy);
	var accommodates = '${requestScope.rdto.accommodates }';
	$("#accommodates").val(accommodates);
	var bedrooms = '${requestScope.rdto.bedrooms }';
	$("#bedrooms").val(bedrooms);
	var phone = '${requestScope.rdto.phone }';
	if(phone.length==10){
		var phone_1 = phone.substring(0,3);
		var phone_2 = phone.substring(3,6);
		var phone_3 = phone.substring(6);
	}else{
		var phone_1 = phone.substring(0,3);
		var phone_2 = phone.substring(3,7);
		var phone_3 = phone.substring(7);
	}
	$("#phone_1").val(phone_1);
	$("#phone_2").val(phone_2);
	$("#phone_3").val(phone_3);
});
</script>
</head>
<body>
<form action="/Project_homeshare_room/modifyroominputbasic.do" method="post" name="form" onsubmit="return chkinput()">

	<input type="hidden" name="roomNo" value=${requestScope.rdto.roomNo }><br>
	<input type="hidden" name="seq" value=${requestScope.rdto.address.seq }>
<h2>회원님의 객실 정보를 수정해주세요.</h2>

<table bgcolor="#F5FFFA" cellpadding="10" cellspacing="0">	
	<tr>
	<td bgcolor="#E0FFFF" width="150">객실종류 </td>
	<td><select name="propertyId" id="propertyId">
				<option value="default">선택해주세요</option>
				<option value="A">아파트</option>
				<option value="B">단독주택</option>
				<option value="C">민박</option>
				<option value="D">원룸</option>
				<option value="E">별장</option>
				<option value="F">다세대주택</option>
				</select></td></tr>
	<tr>			
	<td bgcolor="#F0F8FF">랜트범위 </td>
	<td><select name="privacyId" id="privacyId">
				<option value="default">선택해주세요</option>
				<option value="A">개인방</option>
				<option value="B">다인실</option>
				<option value="C">집/아파트 전체</option>
				</select></td></tr>
	<tr>
	<td bgcolor="#E0FFFF">숙박가능인원 </td>
	<td><select name="accommodates" id="accommodates">
				<option value="default">선택해주세요</option>
				<option>1</option>
				<option>2</option>
				<option>3</option>
				<option>4</option>
				<option>5</option>
				<option>6</option>
				<option>7</option>
				<option>8</option>
				<option>9</option>
				<option>10</option>
				<option>11</option>
				<option>12</option>
				<option>13</option>
				<option>14</option>
				<option>15</option>
				<option>16+</option>				
				</select></td></tr>
	<tr>
	<td bgcolor="#F0F8FF">침실수 </td>
	<td><select name="bedrooms" id="bedrooms">
				<option value="default">선택해주세요</option>
				<option>1</option>
				<option>2</option>
				<option>3</option>
				<option>4</option>
				</select></td></tr>
	<tr>
	<td bgcolor="#E0FFFF">제목 </td>
	<td><input type="text" name="title" value=${requestScope.rdto.title }></td></tr>
	<tr>
	<td bgcolor="#F0F8FF">설명 </td>
	<td><textarea name="description" rows="20" cols="80">${requestScope.rdto.description  }</textarea></td></tr>
	<tr>
	<td bgcolor="#E0FFFF">휴대폰번호 </td>
	<td><select name="phone_1" id="phone_1">
				<option value="default">선택해주세요</option>
				<option value="010">010</option>
				<option value="011">011</option>
				<option value="016">016</option>
				<option value="017">017</option>
				<option value="018">018</option>
				<option value="019">019</option>
				</select> - <input type="text" name="phone_2" maxlength="4" id="phone_2"> - <input type="text" name="phone_3" maxlength="4" id="phone_3"></td></tr>
	<tr>
	<td bgcolor="#F0F8FF">국가 </td>
	<td><input type="text" name="nation" value=${requestScope.rdto.nation }></td></tr>
</table>
<br>
<h4>객실의 위치를 수정해주세요.</h4>
<table bgcolor="#FFFAF0" cellpadding="10" cellspacing="0">
	<tr>
		<td bgcolor="#F0F8FF" width="130"><input type="button" value="주소검색" onclick="searchAddress()" id="e1"></td>
		<td> <font color="red">※ 우편번호를 검색해주세요. </font></td>
	</tr>
	<tr>
	<td bgcolor="#F5F5F5">우편번호 </td>
	<td><input type="text" name="zipcode" id="e2" disabled="disabled" value=${requestScope.rdto.address.zipcode } size="50"></td></tr>
	<tr>
	<td bgcolor="#F0F8FF">시도 </td>
	<td><input type="text" name="sido" id="e3" disabled="disabled" value=${requestScope.rdto.address.sido } size="50"></td></tr>
	<tr>
	<td bgcolor="#F5F5F5">구군 </td>
	<td><input type="text" name="gugun" id="e4" disabled="disabled" value=${requestScope.rdto.address.gugun } size="50"></td></tr>
	<tr>
	<td bgcolor="#F0F8FF">동 </td>
	<td><input type="text" name="dong" id="e5" disabled="disabled" value=${requestScope.rdto.address.dong } size="50"></td></tr>
	<tr>				
	<td bgcolor="#F5F5F5">상세주소 </td>
	<td><input type="text" name="addDetail" value=${requestScope.rdto.addDetail } size="70"></td></tr>
</table>
<p>
	<input type="submit" value="기본정보수정">
	
</form>
</body>
</html>